home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / Mesa-3.0 / SRC / VB.C < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-20  |  1.9 KB  |  74 lines

  1. /* $Id: vb.c,v 3.1 1998/02/20 04:53:07 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  3.0
  6.  * Copyright (C) 1995-1998  Brian Paul
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25.  * $Log: vb.c,v $
  26.  * Revision 3.1  1998/02/20 04:53:07  brianp
  27.  * implemented GL_SGIS_multitexture
  28.  *
  29.  * Revision 3.0  1998/01/31 21:06:45  brianp
  30.  * initial rev
  31.  *
  32.  */
  33.  
  34.  
  35. #ifdef PC_HEADER
  36. #include "all.h"
  37. #else
  38. #include <stdlib.h>
  39. #include "types.h"
  40. #include "vb.h"
  41. #endif
  42.  
  43.  
  44. /*
  45.  * Allocate and initialize a vertex buffer.
  46.  */
  47. struct vertex_buffer *gl_alloc_vb(void)
  48. {
  49.    struct vertex_buffer *vb;
  50.    vb = (struct vertex_buffer *) calloc(sizeof(struct vertex_buffer), 1);
  51.    if (vb) {
  52.       /* set non-zero fields */
  53.       GLuint i, j;
  54.       for (i=0;i<VB_SIZE;i++) {
  55.          vb->MaterialMask[i] = 0;
  56.          vb->ClipMask[i] = 0;
  57.          vb->Obj[i][3] = 1.0F;
  58.          for (j=0;j<MAX_TEX_SETS;j++) {
  59.             vb->MultiTexCoord[j][i][2] = 0.0F;
  60.             vb->MultiTexCoord[j][i][3] = 1.0F;
  61.          }
  62.       }
  63.       vb->TexCoord = vb->MultiTexCoord[0];
  64.       vb->VertexSizeMask = VERTEX3_BIT;
  65.       vb->TexCoordSize = 2;
  66.       vb->MonoColor = GL_TRUE;
  67.       vb->MonoMaterial = GL_TRUE;
  68.       vb->MonoNormal = GL_TRUE;
  69.       vb->ClipOrMask = 0;
  70.       vb->ClipAndMask = CLIP_ALL_BITS;
  71.    }
  72.    return vb;
  73. }
  74.